<div role="main" class="container">
  <div class="container-fluid" style="margin-top:3em;">


    <div class="row-fluid">
	<div ng-show="eventdescriptor.tags">
		<div class="btn btn-info pull-right" ng-repeat="tag in eventdescriptor.tags">
			#{{tag}}  
		</div>
	</div>
      <div class="span13">


<div class="eventdetailframe">
		<h2 class="btn-primary" >
	 {{eventdescriptor.event.name}}
	</h2>
	<span style="margin-top:2em;">
		<i style="font-family:Arial;font-size:16px;"><b>Description</b>: <br>{{eventdescriptor.event.description}}</i>

	</span>

<br>
	<ul class="specs">
		<li><span>Dates and times</span> <br> Event posted: <span
			style="font-size: 1em;"
			am-time-ago="eventdescriptor.event.eventPosted"></span><br> Bet
			deadline : <span style="font-size: 1em;"
			am-time-ago="eventdescriptor.event.betDeadline"></span><br>
			Event starts: <span style="font-size: 1em;"
			am-time-ago="eventdescriptor.event.eventDecidedTime"></span><br></li>
		
		<li><span>Total pot</span>
			<dl>{{betsTotal}}
			</dl></li>

		<li><span>Latest comments</span>
			<dl>
				<div ng-repeat="comment in comments" style="font-style: oblique">
					<dd>
						 <span class="price">{{comment.comment}}</span>
					</dd>
                    <dt>
                        Posted by {{comment.player.firstname}}, <span style="font-size: 1em;"
                                                                      am-time-ago="comment.timePosted"></span>
                    </dt>
				</div>

                <div ng-show="loggedOn" ng-controller="CommentController">
                <button class="btn btn-primary" ng-click="commenton()" ng-hide="showCommentField()">Add comment</button>
                <form name="commentForm" ng-submit="commentEvent(eventdescriptor.event.id)">

                	<div ng-show="showCommentField()">
                <textarea name="comment" ng-maxlength="200" ng-minlength="2" ng-model="comment">Comment</textarea>
                <br>
                    <button type="submit">Add comment</button>
                </div>
                </form>
                    </div>
            </dl>
        </li>

		<li><span>Who proposed it</span>
			<dl>
				<dd>{{eventdescriptor.event.owner.firstname | ownerFilter}}</dd>
			</dl>
		</li>        
	</ul>
</div>

<div class="eventbettables" ng-show="loggedOn" style="height:{{currentframeheight}}">
		
			
<h2 class="btn-primary" >
	 <span>Possible bets</span>
	</h1>			
			<dl>

				<div ng-repeat="owo in eventdescriptor.optionsWithOdds"
					style="font-style: oblique">
					<span class="price"><b>{{owo.option.name}}</b> at {{owo.odds |isNaN}}</span>
					<div ng-show="loggedOn" ng-controller="OptionController">

<div ng-controller="ModalConfirmBetController">
   <script type="text/ng-template" id="confirmBetContent.html">
        <div class="modal-header">
            <h3 class="btn-primary">Confirm bet</h3>
        </div>
        <div class="modal-body">
            
            <ul ng-show="!betconfirmed">
                
						 <div >
						 		
						 		<li>On event <b> {{evdesc.shortname}}</b>, description is <b> {{evdesc.description}}</b></li>
						 		<li>On option <b>{{owo.option.name}}</b></li>
						 		
						 		<li>The amount is {{amount}} betcoins</li>
						 		
						 		<li>The bet will take effect immediately</li>
						 		<button style="margin-right:1em" class="btn btn-primary pull-right" ng-click="close()" ng-show="!betsuccess">Cancel</button>
                                <button class="btn btn-primary pull-left" ng-click="ok()" ng-show="!betsuccess">Confirm</button>
                                
                            </div>     
                            <br>
						

                            <div ng-show="betfailed"><span class="label label-warning">{{retStatus}}</span> </div>

							<div ng-show="betsuccess"><span class="label btn-primary">Bet placed ok!</span>  
							<button class="btn btn-primary pull-right" ng-click="close()">Close this dialogue</button>
							</div>
                                       
                
            </ul>
            <div ng-show="betconfirmed">
                Your bet has been placed. Receipt is available on your account page.
                <button class="btn btn-primary" ng-click="close()">Ok!</button>
            </div>
            <div ng-show="error_occured">
                Failed to register, check your input values
            </div>            
        </div>

    </script>

						

						<form name="simpleForm" ng-submit="openBetConfirm(eventdescriptor,owo,bet)" style="margin: 0px 0px 9px;">
							Amount
                            <input type="number" ng-model="bet.amount" onlyDigits style="width:3em">
								<input type="Submit" class="btn btn-primary" value="Bet" />
								<div ng-show="betfailed"><span class="label label-warning">{{retStatus}}</span>
								</div>
						</form>

</div>
					</div>
				</dl>

		
				</div>





<div class="eventbetlist" ng-show="loggedOn && bets!=null && betsTotal>0">
<span>Latest bets</span>
			<dl>
				<div ng-repeat="bet in bets" style="font-style: oblique">
					<dt>
						{{bet.option.name}}, <span style="font-size: 1em;"
							am-time-ago="bet.timeofbet"></span>
					</dt>
					<dd>
						Amount: <span class="price">{{bet.amount}}</span>
					</dd>

				</div>
			</dl>	
	</div>

</div>
</div>
</div>
</div>